﻿using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore;
using WebAppTemplate.CSR.Repository.DbContexts;

namespace IdentityService.Infrastructure.Migrations
{
    public class AppIdentityDesignTimeDbContextFactory : IDesignTimeDbContextFactory<AppDbContext>
    {
        public AppDbContext CreateDbContext(string[] args)
        {
            DbContextOptionsBuilder<AppDbContext> builder = new DbContextOptionsBuilder<AppDbContext>();

            string connString = "Server=.;Initial Catalog=Demo;User=sa;Password=Yez123!!;TrustServerCertificate=True;";
            builder.UseSqlServer(
                connString,
                it => it.MigrationsHistoryTable("_MigrationsHitory")
            );

            return new AppDbContext(builder.Options);
        }
    }
}
